// 此处第二个参数vm，就是我们在页面使用的this，你可以通过vm获取vuex等操作，更多内容详见uView对拦截器的介绍部分：
const install = (Vue, vm) => {
	let api = {};

	// post 请求
	api.post = (url = '', params = {}) => vm.$u.http.post(url, params);
	// get 请求
	api.get = (url = '', params = {}) => vm.$u.http.get(url, {
		params
	});
	// get 请求(获取文件流)
	api.getFile = (url = '', params = {}) => vm.$u.http.get(url, {
		params,
		responseType: "arraybuffer"
	});
	// put 请求
	api.put = (url = '', params = {}) => vm.$u.http.put(url, params);
	// delete 请求
	api.delete = (url = '', params = {}) => vm.$u.http.delete(url, params);

	//文件上传请求
	api.upload = (url = '', filePath = '', params = {}) => {
		return vm.$u.http.upload(url, {
			filePath: filePath,
			name: 'file',
			formData: params,
		});
	}

	//自定义接口
	api.login = async (params = {}) => await api.get('/user/wxLogin', params); // 登录
	api.uploadFile = async (tempFilePath = "", params = {}) => await api.upload('/common/upload', tempFilePath,
		params); // 上传文件
	api.getPackageList = async (params = {}) => await api.get('/package/list', params); // 获取商城列表 
	api.getPackageDetail = async (params = {}) => await api.get(`/package/${params.id}`); // 获取商城详情
	api.getUserFocusList = async (params = {}) => await api.get('/userFocus/list', params); // 获取关注列表 
	api.getAttractionList = async (params = {}) => await api.get('/attraction/list', params); // 获取景点列表 
	api.getPathList = async (params = {}) => await api.get('/path/list', params); // 获取出行推荐列表 
	api.getLoginOut = async (params = {}) => await api.get('/user/loginOut', params); // 退出登录
	api.getListPathAttraction = async (params = {}) => await api.get('/path/listPathAttraction',
		params); // 获取热门景点详情列表 
	api.getpageList = async (params = {}) => await api.get('/path/pageList', params); // 获取路线推荐详情列表 
	api.getCarPackageList = async (params = {}) => await api.get('/carPackage/list', params); // 获取车辆列表 
	api.getUserPlan = async (params = {}) => await api.post('/userPlan', params); // 新增用户计划
	api.getdictdatatype = async (params = {}) => await api.get(`/dict/data/type/${params.dictType}`); // 字典
	api.getlocateCitye = async (params = {}) => await api.get('/user/locateCity', params); // 获取当前定位城市
	api.getlistEconomize = async (params = {}) => await api.get('/area/listEconomize', params); // 获取当前定位城市
	api.getlistMarket = async (params = {}) => await api.get('/area/listMarket/'); // 获取当前定位城市
	api.getpathlist = async (params = {}) => await api.get(`/path/${params.id}`); // 获取当前定位城市
	api.getmomentlist = async (params = {}) => await api.get('/moment/list', params); // 获取攻略列表
	api.getmomentDetail = async (params = {}) => await api.get(`/moment/${params.id}`); // 获取攻略列表详情
	// api.getuserPlan = async (params = {}) => await api.post('/userPlan', params); // 创建订单
	api.getuserPlancountAmount = async (params = {}) => await api.post('/userPlan/countAmount', params); // 计算价格
	api.getwxpay = async (params = {}) => await api.post('/wxpay/pay', params); // 支付
	api.getupdateUser = async (params = {}) => await api.put('/user/updateUser', params); // 修改用户信息
	api.getqueryUser = async (params = {}) => await api.get('/user/queryUser', params); // 获取用户信息
	api.getuserFocus = async (params = {}) => await api.get('/userFocus/listFocusUser', params); // 获取关注列表
	api.getfocusOrCancelFocusUser = async (params = {}) => await api.get('/userFocus/focusOrCancelFocusUser',
		params); // 关注用户，取消关注
	api.getcreateOrder = async (params = {}) => await api.post('/order/createOrder', params); // 商城创建订单
	api.getcarousel = async (params = {}) => await api.get('/carousel/list', params); // 轮播图
	api.getorderlist = async (params = {}) => await api.get('/order/list', params); // 订单列表
	api.getmomentComments = async (params = {}) => await api.post('/momentComments', params); // 评论
	api.getmomentCommentslist = async (params = {}) => await api.get(`/momentComments/byMomentId/${params.id}`,
		params); // 评论列表
	api.getfeedback = async (params = {}) => await api.post('/feedback', params); // 反馈
	api.getorderDetail = async (params = {}) => await api.get(`/order/${params.id}`); // 获取订单详情
	api.getorderCancel = async (params = {}) => await api.delete(`/order/cancel/${params.id}`); // 取消订单
	api.getorder = async (params = {}) => await api.delete(`/order/${params.id}`); // 删除订单
	api.getstartOrder = async (params = {}) => await api.put(`/order/startOrder/${params.orderNumber}`); // 开始订单
	api.getconfirmOrder = async (params = {}) => await api.put(
		`order/confirmOrder/${params.orderNumber}`); // 确认订单结束
	api.getwallMessagelist = async (params = {}) => await api.get('/wallMessage/list', params); // 获取留言墙
	api.getwallMessage = async (params = {}) => await api.post('/wallMessage', params); // 发布留言墙
	api.getmomentmyList = async (params = {}) => await api.get('/moment/myList', params); // 我的攻略列表
	api.getmomentpushMoment = async (params = {}) => await api.post('/moment/pushMoment', params); // 发布动态
	api.getOrderPath = async (params = {}) => await api.get('/order/getOrderPath/', params); // 获取景点路线
	api.getdeletemoment = async (params = {}) => await api.delete(`/moment/${params.id}`, ); // 删除我的攻略
	api.getdelmomentComments = async (params = {}) => await api.delete(
		`/momentComments/${params.id}`, ); // 删除我的攻略的评论
	api.getorderPathAttraction = async (params = {}) => await api.get(
		`/orderPathAttraction/queryByOrder/${params.id}`, ); // 我的订单的景点路线
	api.getregisterAudit = async (params = {}) => await api.post('/registerAudit/', params); // 摄影师司机注册
	api.getattractionDetail = async (params = {}) => await api.get(`/attraction/${params.id}`); // 景点详情
	api.getlistOtherOrder = async (params = {}) => await api.get('/order/listOtherOrder/'); // 所有订单
	api.gethomepage = async (params = {}) => await api.get(`/user/getUser/${params.focusUid}`); // 关注用户主页
	api.getqueryFocusUserMomentsge = async (params = {}) => await api.get(
		`/moment/queryFocusUserMoments?uid=${params.uid}`, params); // 关注用户动态详情
	api.getchatlist = async (params = {}) => await api.get('/chat/list', params); // 查询我的聊天列表
	api.getchatMessagelist = async (params = {}) => await api.get(`/chatMessage/list?chatId=${params.chatId}`,
		params); // 查询聊天室消息
	api.getchatMessage = async (params = {}) => await api.post('/chatMessage/', params); // 查询聊天室消息
	api.getlistHotCity = async (params = {}) => await api.get('/area/listHotCity/', params); // 查询热门城市
	api.getqueryByArea = async (params = {}) => await api.get('/mapPoint/queryByArea/', params); // 查询地图图片
	api.getorderAttractionImage = async (params = {}) => await api.post('/orderAttractionImage/selectImage',
		params); // 提交图片
	api.getconfigKey = async (params = {}) => await api.get(`/config/configKey/${params.configKey}`,
		params); // 查询基础照片数量
	api.getuserPlanList = async (params = {}) => await api.get('/userPlan/list', params); // 查询我的路线
	api.getaddImage = async (params = {}) => await api.post('/order/addImage', params); // 加照片
	api.getPhotoAmount = async (params = {}) => await api.get('/package/getPhotoAmount', params); // 计算价格
	api.getarea = async (params = {}) => await api.get(`/area/${params.id}`); // 客服二维码
	api.getphotodetails = async (params = {}) => await api.get(
		`/orderAttractionImage/list?orderId=${params.orderId}&attractionId=${params.attractionId}`
	); // 查询景点列表接口

	// 将各个定义的接口名称，统一放进对象挂载到vm.$u.api(因为vm就是this，也即this.$u.api)下
	vm.$u.api = api;
}

export default {
	install
}